import {all, takeEvery} from 'redux-saga/effects'
import {
    departListFetch,
    doctorListFetch,
    hospitalListFetch,
    patientListFetch,
    requestDepartList,
    requestDoctorList,
    requestHospitalList,
    requestPatientList
} from "./actions";
import { getMedicalcard, medicalcardSet } from "./modules/medicalcard/action";

function* watchFetchHospitalList() {
  yield takeEvery(hospitalListFetch, requestHospitalList);
}

function* watchFetchDepartList() {
  yield takeEvery(departListFetch, requestDepartList);
}

function* watchFetchDoctorList() {
  // @ts-ignore
  yield takeEvery(doctorListFetch, requestDoctorList);
}

function* getCardList() {
  yield takeEvery(medicalcardSet, getMedicalcard);
}
function* watchFetchPatientList() {
    // @ts-ignore
    yield takeEvery(patientListFetch, requestPatientList);
}


export default function* sagas() {
    yield all([
        watchFetchHospitalList(),
        watchFetchDoctorList(),
        watchFetchDepartList(),
        watchFetchPatientList(),
        getCardList()
    ])
}